package com.imut.lagain.repository;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.imut.lagain.entity.MoodThief;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 心情小偷数据访问层
 */
@Mapper
public interface MoodThiefRepository extends BaseMapper<MoodThief> {
    
    /**
     * 根据小偷类型查询心情小偷
     * @param thiefType 小偷类型
     * @return 心情小偷信息
     */
    @Select("SELECT * FROM mood_thief WHERE thief_type = #{thiefType} AND is_deleted = 0")
    MoodThief findByThiefType(@Param("thiefType") String thiefType);
    
    /**
     * 查询未删除的心情小偷列表
     * @param page 分页参数
     * @return 心情小偷分页列表
     */
    @Select("SELECT * FROM mood_thief WHERE is_deleted = 0 ORDER BY create_time DESC")
    IPage<MoodThief> findActiveMoodThieves(Page<MoodThief> page);
    
    /**
     * 根据显示名称模糊查询心情小偷
     * @param displayName 显示名称关键字
     * @param page 分页参数
     * @return 心情小偷分页列表
     */
    @Select("SELECT * FROM mood_thief WHERE display_name LIKE CONCAT('%', #{displayName}, '%') AND is_deleted = 0 ORDER BY create_time DESC")
    IPage<MoodThief> findByDisplayNameLike(@Param("displayName") String displayName, Page<MoodThief> page);
    
    /**
     * 查询所有未删除的心情小偷
     * @return 心情小偷列表
     */
    @Select("SELECT * FROM mood_thief WHERE is_deleted = 0 ORDER BY create_time DESC")
    List<MoodThief> findAllActive();
}
